package com.googlecode.tracey.ui.core;

import com.googlecode.totallylazy.Callable1;
import com.googlecode.totallylazy.Pair;

import java.util.Map;

import static com.googlecode.totallylazy.Callables.returns;

public class MessageServer extends Pair<String,String> {

    private MessageServer(String name, String url) {
        super(returns(name), returns(url));
    }

    public static MessageServer messageServer(String name, String url) {
        return new MessageServer(name, url);
    }

    public static Callable1<Map<String, Object>, MessageServer> fromMap() {
        return new Callable1<Map<String, Object>, MessageServer>() {
            @Override
            public MessageServer call(Map<String, Object> map) throws Exception {
                return messageServer(map.get("name").toString(), map.get("url").toString());
            }
        };
    }
}
